Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Sound

| Previous | Chapter contents | Chapter top | Section top | Next |

Obtaining Information

To obtain information about whether a computer supports certain sound features, you should use the Gestalt function, documented in Inside Macintosh: Operating System Utilities . Sometimes, however, you might need information the Gestalt function is not able to provide. The Sound Manager provides a number of routines that you can use to obtain additional sound-related information.

You can obtain the version numbers of the Sound Manager and the MACE tools by calling the SndSoundManagerVersion and MACEVersion functions, respectively. You can obtain information about a sound channel and about all sound channels by calling the SndControl , SndChannelStatus , and SndManagerStatus functions, respectively.

The Sound Manager includes two routines-- SndGetSysBeepState and SndSetSysBeepState --that allow you to determine and alter the status of the system alert sound.

To play a sound resource using low-level Sound Manager routines, you need the address of the sound header stored in the sound resource. Sound Manager versions 3.0 and later provide the GetSoundHeaderOffset function that you can use to obtain that information.

SndSoundManagerVersion

You can use SndSoundManagerVersion to determine the version of the Sound Manager tools available on a computer.

FUNCTION SndSoundManagerVersion: NumVersion;

DESCRIPTION

The SndSoundManagerVersion function returns a version number that contains the same information as in the first 4 bytes of a 'vers' resource. You might use the SndSoundManagerVersion function to determine if a computer has the enhanced Sound Manager, which is necessary for multichannel sound and for continuous plays from disk.

SPECIAL CONSIDERATIONS

You can call the SndSoundManagerVersion function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the SndSoundManagerVersion function are

Trap macro

Selector

_SoundDispatch

$000C0008

SEE ALSO

For information on how to use the SndSoundManagerVersion function to determine whether the enhanced Sound Manager is available, see "Obtaining Version Information" .

MACEVersion

You can use MACEVersion to determine the version of the MACE tools available on a machine.

FUNCTION MACEVersion: NumVersion;

DESCRIPTION

The MACEVersion function returns a version number that contains the same information as in the first 4 bytes of a 'vers' resource.

SPECIAL CONSIDERATIONS

You can call the MACEVersion function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the MACEVersion function are

Trap macro

Selector

_SoundDispatch

$00000010

SndControl

You can obtain information about a sound data type by using the SndControl function. In Sound Manager version 3.0 and later, however, you virtually never need to call SndControl . The capabilities that SndControl provides are either provided by the Gestalt function or are no longer supported. The SndControl function is documented here for completeness only.

FUNCTION SndControl (id: Integer; VAR cmd: SndCommand): OSErr;
id
The sound data type you want to get information about.
cmd
A sound command.

DESCRIPTION

The SndControl function sends a control command directly to the Sound Manager to get information about a specific data type. The available data types are specified by constants:

CONST
    squareWaveSynth         = 1;        {square-wave data}
    waveTableSynth          = 3;        {wave-table data}
    sampledSynth            = 5;        {sampled-sound data}

You can call SndControl even if no channel has been created for the type of data you want to get information about. SndControl can be used with the availableCmd or versionCmd sound commands to request information. The requested information is returned in the sound command record specified by the cmd parameter.

The SndControl function can indicate only whether a particular data format supports some feature (for example, stereo output), not whether the available sound hardware also supports that feature. In general, you should use the Gestalt function to determine whether the sound features you need are available in the current operating environment.

In Sound Manager version 2.0, you can also use the totalLoadCmd and loadCmd commands to get information about the amount of CPU time consumed by sound-related processing. However, these commands are not very accurate and are not supported by version 3.0 and later.

SPECIAL CONSIDERATIONS

You should not call the SndControl function at interrupt time.

RESULT CODES

noErr

0

No error

SEE ALSO

See the list of sound commands in "Sound Command Numbers" for a complete description of the sound commands supported by SndControl .

SndChannelStatus

You can use the SndChannelStatus function to determine the status of a sound channel.

FUNCTION SndChannelStatus (chan: SndChannelPtr;
                                         theLength: Integer;
                                         theStatus: SCStatusPtr): OSErr;
chan
A pointer to a valid sound channel.
theLength
The size in bytes of the sound channel status record. You should set this field to SizeOf(SCStatus) .
theStatus
A pointer to a sound channel status record.

DESCRIPTION

If the SndChannelStatus function executes successfully, the fields of the record specified by theStatus accurately describe the sound channel specified by chan .

SPECIAL CONSIDERATIONS

You can call the SndChannelStatus function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the SndChannelStatus function are

Trap macro

Selector

_SoundDispatch

$00100008

RESULT CODES

noErr

0

No error

paramErr

-50

A parameter is incorrect

badChannel

-205

Channel is corrupt or unusable

SEE ALSO

For information on the structure of a sound channel status record, see "Sound Channel Status Records" .

SndManagerStatus

You can use the SndManagerStatus function to determine information about all sound channels currently allocated.

FUNCTION SndManagerStatus (theLength: Integer;
                                         theStatus: SMStatusPtr): OSErr;
theLength
The size in bytes of the Sound Manager status record. You should set this field to SizeOf(SMStatus) .
theStatus
A pointer to a Sound Manager status record.

DESCRIPTION

The SndManagerStatus function determines information about all currently allocated sound channels. If the SndManagerStatus function executes successfully, the fields of the record specified by theStatus accurately describe the current status of the Sound Manager.

SPECIAL CONSIDERATIONS

You can call the SndManagerStatus function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the SndManagerStatus function are

Trap macro

Selector

_SoundDispatch

$00140008

RESULT CODES

noErr

0

No error

SndGetSysBeepState

You can use the SndGetSysBeepState procedure to determine if the system alert sound is enabled.

PROCEDURE SndGetSysBeepState (VAR sysBeepState: Integer);
sysBeepState
On exit, the state of the system alert sound.

DESCRIPTION

The SndGetSysBeepState procedure returns one of two states in the sysBeepState parameter, either the sysBeepDisable or the sysBeepEnable constant.

CONST
    sysBeepDisable          = $0000;        {system alert sound disabled}
    sysBeepEnable           = $0001;        {system alert sound enabled}

SPECIAL CONSIDERATIONS

You can call the SndGetSysBeepState procedure at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the SndGetSysBeepState procedure are

Trap macro

Selector

_SoundDispatch

$00180008

SndSetSysBeepState

You can use the SndSetSysBeepState function to set the state of the system alert sound.

FUNCTION SndSetSysBeepState (sysBeepState: Integer): OSErr;
sysBeepState
The desired state of the system alert sound.

DESCRIPTION

You can use the SndSetSysBeepState function to temporarily disable the system alert sound while you play a sound and then enable the alert sound when you are done. The  sysBeepState parameter should be set to either sysBeepDisable or sysBeepEnable .

If your application disables the system alert sound, be sure to enable it when your application gets a suspend event.

SPECIAL CONSIDERATIONS

You can call the SndSetSysBeepState function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the SndSetSysBeepState function are

Trap macro

Selector

_SoundDispatch

$001C0008

RESULT CODES

noErr

0

No error

paramErr

-50

A parameter is incorrect

GetSoundHeaderOffset

You can use the GetSoundHeaderOffset function to get the offset from the beginning of a sound resource to the embedded sound header.

FUNCTION GetSoundHeaderOffset (sndHdl: Handle;
                                         VAR offset: LongInt): OSErr;
sndHdl
A handle to a sound resource.
offset
On exit, the offset from the beginning of the sound resource specified by the sndHdl parameter to the beginning of the sound header within that sound resource.

DESCRIPTION

The GetSoundHeaderOffset function returns, in the offset parameter, the number of bytes from the beginning of the sound resource specified by the sndHdl parameter to the sound header that is contained within that resource. You might need this information if you want to use the address of that sound header in a sound command (such as the soundCmd or bufferCmd sound command).

The handle passed to GetSoundHeaderOffset does not have to be locked.

SPECIAL CONSIDERATIONS

The GetSoundHeaderOffset function is available only in version 3.0 and later of the Sound Manager. See "Obtaining a Pointer to a Sound Header" for a function you can call in earlier versions of the Sound Manager to obtain the same information.

You can call the GetSoundHeaderOffset function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the GetSoundHeaderOffset function are

Trap macro

Selector

_SoundDispatch

$04040024

RESULT CODES

noErr

0

No error

badFormat

-206

Resource is corrupt or unusable

SEE ALSO

See Listing 1-37 for an example of calling GetSoundHeaderOffset.


© 1999 Apple Computer, Inc.

| Previous | Chapter contents | Chapter top | Section top | Next |